package com.lxb;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class StrStr {
    public static void main(String[] args) {

        String haystack = "aaa";
        String needle = "a";

        int str2 = needle.length();
        int str1 = haystack.length();

        int num = -1;

        for(int i=0;i<=str1-str2;i++){
            String substring = haystack.substring(i, i + str2);
            if(substring.equals("")){
                num = 0;
                break;
            }
               if(substring.equals(needle)){
                   num = i;
                   break;
               }
        }

        System.out.println(num);

    }
}
